package com.linkage.jz.bankruptcy.bean.Vote;

import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @author AFAP
 * 表决人详情-分组
 */
public class VoterGroup {

    private long opAt; //
    private boolean other; // 是否其他分组
    private String code; // 分组编号
    private int memberCount; // 当前状态表决人数
    private boolean guarantee; // 是否担保分组
    private boolean ordinary; // 是否普通分组
    private String voteId; // 表决id
    private int sort; // 排序序号
    private String opBy; //
    private boolean delFlag; //
    private String name; // 分组名称
    private boolean canDelete; // 能否删除
    private String id; // 分组ID
    private double totalVoteMoney; // 合计表决金额
    private List<VoterDetail> memberDetailList = new ArrayList<>();

    // 额外附加信息
    private boolean real = true; // 未分组的虚拟组
    private boolean expand = false;
    private int totalPage = 1; // 分组成员总页数
    private int currentPage = 0; // 当前已经加载的页数


    public long getOpAt() {
        return opAt;
    }

    public void setOpAt(long opAt) {
        this.opAt = opAt;
    }

    public boolean isOther() {
        return other;
    }

    public void setOther(boolean other) {
        this.other = other;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public int getMemberCount() {
        return memberCount;
    }

    public void setMemberCount(int memberCount) {
        this.memberCount = memberCount;
    }

    public boolean isGuarantee() {
        return guarantee;
    }

    public void setGuarantee(boolean guarantee) {
        this.guarantee = guarantee;
    }

    public boolean isOrdinary() {
        return ordinary;
    }

    public void setOrdinary(boolean ordinary) {
        this.ordinary = ordinary;
    }

    public String getVoteId() {
        return voteId;
    }

    public void setVoteId(String voteId) {
        this.voteId = voteId;
    }

    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }

    public String getOpBy() {
        return opBy;
    }

    public void setOpBy(String opBy) {
        this.opBy = opBy;
    }

    public boolean isDelFlag() {
        return delFlag;
    }

    public void setDelFlag(boolean delFlag) {
        this.delFlag = delFlag;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isCanDelete() {
        return canDelete;
    }

    public void setCanDelete(boolean canDelete) {
        this.canDelete = canDelete;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public double getTotalVoteMoney() {
        return totalVoteMoney;
    }

    public void setTotalVoteMoney(double totalVoteMoney) {
        this.totalVoteMoney = totalVoteMoney;
    }

    public List<VoterDetail> getMemberDetailList() {
        return memberDetailList;
    }

    public void setMemberDetailList(List<VoterDetail> memberDetailList) {
        this.memberDetailList = memberDetailList;
    }

    public boolean isExpand() {
        return expand;
    }

    public void setExpand(boolean expand) {
        this.expand = expand;
    }


    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public boolean isReal() {
        return real;
    }

    public void setReal(boolean real) {
        this.real = real;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof VoterGroup) {
            return TextUtils.equals(this.getId(), ((VoterGroup) obj).getId());
        }
        return false;
    }

    public static List<VoterGroup> parse(JsonArray arr) {
        List<VoterGroup> list = new ArrayList<>();
        for (int i = 0; i < arr.size(); i++) {
            list.add(parse(arr.get(i).getAsJsonObject()));
        }
        return list;
    }

    public static VoterGroup parse(JsonObject obj) {
        VoterGroup bean = new Gson().fromJson(obj, VoterGroup.class);
        return bean;
    }
}
